<?php

require ('Stencil.php');
require_once( 'util.php' );
if (!is_logged())
{
	report_err_and_exit( '请先登录' );
}

require ('dbconnect.php');
output_frame_header ( '个人用户' );

$userName = $_SESSION ['userName'];
$u_id = $_SESSION ['u_id'];
$gender = $_SESSION ['gender'];
$group = $_SESSION ['group'];
$phone = $_SESSION ['phone'];
$address = $_SESSION ['address'];
$birthday = $_SESSION ['birthday'];
$occupation = $_SESSION ['occupation'];
$blood_type = $_SESSION ['blood_type'];
$weibo = $_SESSION ['weibo'];
$qq = $_SESSION ['qq'];
$u_image = $_SESSION ['u_image'];
$s_question = $_SESSION ['s_question'];
$s_answer = $_SESSION ['s_answer'];
$mail = $_SESSION ['mail'];
?>

<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="style/validator.css"></link>
<script src="formValidator-4.0.1.js" type="text/javascript"
	charset="UTF-8"></script>
<script src="formValidatorRegex.js" type="text/javascript"
	charset="UTF-8"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$.formValidator.initConfig({
			formID : "modify_form",
			onError : function() {
				alert("校验没有通过，具体错误请看错误提示")
			}
		});
			$("#birthday").formValidator({
			onShow : "请输入的出生日期",
			onFocus : "请输入的出生日期",
			onCorrect : "你输入的日期合法"
		}).inputValidator({
			min : "1900-01-01",
			max : "2010-12-31",
			type : "date",
			onError : "在\"1900-01-01\"和\"2010-12-31\"之间"
		}).defaultPassed();
		$("#email").formValidator({
			onShow : "请输入你的email",
			onfocus : "请输入你的email",
			onCorrect : "你的email正确"
		}).regexValidator({
			regExp : "email",
			dataType : "enum",
			onError : "email格式不正确"
		});
	});
</script>


<!-- 空格 -->
<!-- 内容部分 -->
<div id="wp" class="wp ">
	<!-- 在此书写内容设计 -->
	<table>
		<tbody>
			<tr>
				<!-- 左边菜单栏 -->
				<td background="images/option.jpg">
					<?php require_once( 'settings.inc.php' ); ?>
				</td>
				<!-- 右边修改 -->
				<td>
					<table>

						<tbody>
							<tr>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<!-- 修改头像部分 -->
								<td width="150" valign="top">
									<!-- 头像图片 -->
									<div>
										<big>当前头像：</big>
									</div>
									<div>&nbsp;</div>
									<div align="center">
										<img height="100" src="userphoto/<?php echo $u_id;?>" alt="" onerror="javescript:this.src='images/touxiang.jpg'" >
									</div> <!-- 更换图片按键 -->
									<div>&nbsp;</div>
									<div>
										<form action="add_userphoto.php" method="post"
											enctype="multipart/form-data">
											<div>
												<small><font color="#79FF79"> ( 请从电脑中选择图片文件 )</font></small>
												<input type="file" name="photo" id="file"
													onchange="yanzheng()" style="width: 180px;"> <input
													type="hidden" name="submitted" value="TRUE" /> <input
													type="submit" name="submit" value="上传">
											</div>
										</form>
										<!---->
									</div>
								</td>
								<!-- 修改个人资料部分 -->
								<td>
									<table>
										<form action="modify.php" method="post" name="modify_form"
											id="modify_form">
											<tr>
												<td>&nbsp;</td>
											</tr>
											<tr>
												<td width="100" height="35" align="right">用户</td>
												<td width="10"></td>
												<td width="268">
											    <?php
															echo <<<ROD
                                                 {$_SESSION['userName']}
ROD;
															?>
  										
												<!-- 从数据库读取 -->
												</td>
											</tr>
											<tr>
												<td width="100" height="35" align="right">性别</td>
												<td width="10"></td>
												<?php
												if($gender=="男"){
												echo<<<ROD
												<td><input id="man" name="gender" type="radio" value="男" checked="checked"
													><label for="man">男</label>&nbsp;&nbsp;&nbsp;&nbsp;
													<input id="woman" name="gender" type="radio"
													value="女" ><label
													for="woman">女</label> <span style="display: none" id=""></span></td>
ROD;
}
else{                                           
												echo<<<ROD
												<td><input id="man" name="gender" type="radio" value="男"
													><label for="man">男</label>&nbsp;&nbsp;&nbsp;&nbsp;
													<input id="woman" name="gender" type="radio"
													value="女" checked="checked"><label
													for="woman">女</label> <span style="display: none" id=""></span></td>
ROD;
}
?>
											</tr>
											<tr>
												<td width="90" height="35" align="right">出生日期</td>
												<td width="30"></td>
												<td width="268"><input type="text" id="birthday"
													name="birthday" style="width: 250px"
													value=<?php echo $birthday; ?>></td>
												<td><div id="birthdayTip" style="width: 200px"></div></td>
											</tr>
											<tr>
												<td width="100" height="35" align="right">电子邮箱</td>
												<td width="10"></td>
												<td width="268"><input type="text" id="email" name="email"
													value="<?php echo $mail; ?>" style="width: 250px"></td>
												<td><div id="emailTip" style="width: 200px"></div></td>
											</tr>
											<tr>
												<td width="90" height="35" align="right">电话</td>
												<td width="10"></td>
												<td width="268"><input type="text" id="phone" name="phone"
													style="width: 250px;" value=<?php echo $phone; ?>></td>

											</tr>
											<tr>
												<td width="100" height="35" align="right">地址</td>
												<td width="10"></td>
												<td width="268"><input type="text" id="address"
													name="address" style="width: 250px;"
													value=<?php echo $address; ?>></td>
											</tr>
											<tr>
												<td width="100" height="35" align="right">qq</td>
												<td width="10"></td>
												<td width="268"><input type="text" id="qq" name="qq"
													style="width: 250px;" value=<?php echo $qq; ?>></td>
											</tr>
											<tr>
												<td width="100" height="35" align="right">微博</td>
												<td width="10"></td>
												<td width="268"><input type="text" id="weibo" name="weibo"
													style="width: 250px;" value=<?php echo $qq; ?>></td>
											</tr>
											<tr>
												<td width="100" height="35" align="right">职业</td>
												<td width="10"></td>
												<td width="268"><input type="text" id="occupation"
													name="occupation" style="width: 250px;"
													value=<?php echo $occupation; ?>></td>
											</tr>
											<tr>
												<td width="100" height="35" align="right">血型</td>
												<td width="10"></td>
												<?php												
												if($blood_type=="A"){
												echo<<<ROD
												<td width="325">
												<select name="blood_type" id="blood_type"
													style="width: 256px">
														<option value="A" selected>A型</option>
														<option value="B">B型</option>
														<option value="AB">AB型</option>
														<option value="O">O型</option>
														<option value="其他">其他</option>
												</select></td>
ROD;
}
												if($blood_type=='B'){
												echo<<<ROD
												<td width="325">
												<select name="blood_type" id="blood_type"
													style="width: 256px">
														<option value="A" >A型</option>
														<option value="B" selected>B型</option>
														<option value="AB">AB型</option>
														<option value="O">O型</option>
														<option value="其他">其他</option>
												</select></td>
ROD;
}
												if($blood_type=="AB"){
												echo<<<ROD
												<td width="325">
												<select name="blood_type" id="blood_type"
													style="width: 256px">
														<option value="A" >A型</option>
														<option value="B">B型</option>
														<option value="AB" seletde>AB型</option>
														<option value="O">O型</option>
														<option value="其他">其他</option>
												</select></td>
ROD;
}
												if($blood_type=="O"){
												echo<<<ROD
												<td width="325">
												<select name="blood_type" id="blood_type"
													style="width: 256px">
														<option value="A" >A型</option>
														<option value="B">B型</option>
														<option value="AB">AB型</option>
														<option value="O" selected>O型</option>
														<option value="其他">其他</option>
												</select></td>
ROD;
}
												if($blood_type!="A"&&$blood_type!="B"&&$blood_type!="AB"&&$blood_type!="O"){
												echo<<<ROD
												<td width="325">
												<select name="blood_type" id="blood_type"
													style="width: 256px">
														<option value="A" >A型</option>
														<option value="B">B型</option>
														<option value="AB">AB型</option>
														<option value="O" >O型</option>
														<option value="其他" selected>其他</option>
												</select></td>
ROD;
}
?>
											</tr>
											<tr>
												<td>&nbsp;</td>
											</tr>
											<tr>
												<td width="100" height="35" align="right"></td>
												<td width="10"></td>
												<td><input type="image" src="images/submit.jpg" width="60"
													height="25" name="submit" id="submit" value="提交"></td>
											</tr>
																						<tr>
												<td>&nbsp;</td>
											</tr>											<tr>
												<td>&nbsp;</td>
											</tr>
										</form>
									</table>
								</td>

							</tr>
						</tbody>

					</table>
			
			</tr>
	
	</table>
</div>
<div class="space"></div>
<?php output_frame_footer();?>
